package com.ruoyi.system.controller.Evaluating;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Evaluating.ModelMethod;
import com.ruoyi.system.service.Evaluating.IModelMethodService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 评估方法Controller
 *
 * @author ruoyi
 * @date 2024-07-09
 */
@RestController
@RequestMapping("/modelMethod/modelMethod")
public class ModelMethodController extends BaseController
{
    @Autowired
    private IModelMethodService modelMethodService;

    /**
     * 查询评估方法列表
     */
    @PreAuthorize("@ss.hasPermi('modelMethod:modelMethod:list')")
    @GetMapping("/list")
    public TableDataInfo list(ModelMethod modelMethod)
    {
        startPage();
        List<ModelMethod> list = modelMethodService.selectModelMethodList(modelMethod);
        return getDataTable(list);
    }

    /**
     * 导出评估方法列表
     */
    @PreAuthorize("@ss.hasPermi('modelMethod:modelMethod:export')")
    @Log(title = "评估方法", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ModelMethod modelMethod)
    {
        List<ModelMethod> list = modelMethodService.selectModelMethodList(modelMethod);
        ExcelUtil<ModelMethod> util = new ExcelUtil<ModelMethod>(ModelMethod.class);
        util.exportExcel(response, list, "评估方法数据");
    }

    /**
     * 获取评估方法详细信息
     */
    @PreAuthorize("@ss.hasPermi('modelMethod:modelMethod:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(modelMethodService.selectModelMethodById(id));
    }

    /**
     * 新增评估方法
     */
    @PreAuthorize("@ss.hasPermi('modelMethod:modelMethod:add')")
    @Log(title = "评估方法", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ModelMethod modelMethod)
    {
        modelMethod.setUserId(getUserId());
        modelMethod.setDeptId(getDeptId());
        return toAjax(modelMethodService.insertModelMethod(modelMethod));
    }

    /**
     * 修改评估方法
     */
    @PreAuthorize("@ss.hasPermi('modelMethod:modelMethod:edit')")
    @Log(title = "评估方法", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ModelMethod modelMethod)
    {
        return toAjax(modelMethodService.updateModelMethod(modelMethod));
    }

    /**
     * 删除评估方法
     */
    @PreAuthorize("@ss.hasPermi('modelMethod:modelMethod:remove')")
    @Log(title = "评估方法", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(modelMethodService.deleteModelMethodByIds(ids));
    }
}
